package com.vf.editor.mvc.scene.property;

import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.vf.editor.common.model.resources.ScenePoint;
import com.vf.editor.common.model.resources.SceneProperty;

public class PropertyService {
	
	public void saveOrUpdateThing(SceneProperty property) {
		
		try {
			if(StrKit.equals("ip", property.getCode()) && !StrKit.isBlank(property.getValue())) {
				ScenePoint scenePoint = ScenePoint.dao.findById(property.getThingId());
				if(scenePoint!=null) {
					Record record = Db.use("airport").findFirst("SELECT * FROM EQUIPMENT WHERE DEVICE_IP=? ",property.getValue());
					if(record!=null && !StrKit.isBlank(record.getStr("DEVICE_IP"))) {
						scenePoint.setSrcId(record.getStr("SRCID"));
						scenePoint.update();
					}
				}
			}
		} catch (Exception e) {
		}
	}
	
}
